using UnityEngine;
namespace ZFramework.Runtime
{
    //ui对象池封装
    public class UIFormInstanceObject : ObjectBase
    {
        private IUIFormHelper _uiFormHelper;
        private Object _uiAsset;
        
        public override void Release()
        {
            _uiFormHelper.ReleaseUIForm(Name, (Object)Instance);
        }

        public static UIFormInstanceObject Create(string name, Object asset, Object instance, IUIFormHelper uiFormHelper)
        {
            var instanceObject = ReferencePool.Acquire<UIFormInstanceObject>();
            instanceObject.Initialize(name, instance);
            instanceObject._uiAsset = asset;
            instanceObject._uiFormHelper = uiFormHelper;
            return instanceObject;
        }

        public override void Clear()
        {
            base.Clear();
            _uiAsset = null;
        }

    }
}